Complex Assignment (CA)

Description:

CA checks for occurrences of multiple assignments and assignments to variables within the same expression. You should avoid using assignments that are too complex, since they decrease program readability.

If the Strict option is unchecked, assignments of the same value to several variables in one operation are permitted. For example, consider the following statement:

i = j = k = 0;

This statement will raise a violation if the Strict option is checked in the audit properties, but there will be no violation if it is unchecked.

Incorrect:

// compound assignment
i *= j++;
k = j = 10;
l = j += 15;

// nested assignment
i = j++ +20;
i = (j = 25) + 30;

Correct:

// instead of i *= j++; 
i *= j;
j++;

// instead of k = j = 10;
k = 10;
j = 10;

// instead of l = j += 15;
j += 15;
l = j;

// instead of i = j++ + 20;
i = j + 20;
j++;

// instead of i = (j = 25) + 30;
j = 25;
i = j + 30;